package com.zeking.service;

import com.zeking.bean.User;
import com.zeking.dao.BasePageBean;
import com.zeking.dao.UserDao;
import com.zeking.factory.UserDaoFactory;

public class UserService {
    private UserDao userDao;

    public UserService() {
        this.userDao = UserDaoFactory.getUserDao();
    }

    /**
     * 自定义成员方法实现根据参数指定的User对象来调用DAO层实现登录功能
     *
     * @param
     * @return
     */
    public User userLoginService(String name, String password) {
        return userDao.userLogin(name, password);
    }

    /**
     * 分页获取 用户 数据
     *
     * @param
     * @return
     */
    public BasePageBean<User> getUserByLimit(int currentPage, int pageSize) {
        return userDao.getUserByLimit(currentPage, pageSize);
    }

    /**
     * 添加用户
     *
     * @param user
     */
    public void addUser(User user) {
        userDao.addUser(user);
    }

    /**
     * 通过uid 删除用户
     *
     * @param uid
     */
    public void deleteUserByUid(int uid) {
        userDao.deleteUserByUid(uid);
    }

    /**
     * 修改用户
     *
     * @param user
     */
    public void updateUser(User user) {
        userDao.updateUser(user);
    }
}
